
#import "MainScreen.h"
#import "SettingScreen.h"
#import "WeaponUpgradesScreen.h"
#import "HelpScreen.h"
 
#import "TYAddLifeProps.h"
//#import "TYFarmer.h"

@implementation MainScreen

/**
 * @brief 销毁函数
 *
 * @param[in] nil
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
- (void) dealloc {
	CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
	
	[super dealloc];
}

/**
 * @brief 函数功能说明
 *
 * @param[in] 入参
 * @param[out] 出参
 *
 * @return 返回值
 *
 * @note注解
 * @par 示例:
 *
 * @code
 ...示例代码
 * @endcode
 *
 * @see 参见
 * @deprecated 有新的替代方法可用,不建议再使用
 */
+(id) scene {
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	MainScreen *layer = [MainScreen node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

#pragma mark 静态函数群
/**
 * @brief 创建新游戏
 *
 * @param[in] (id) sender : 
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
- (void) newGame:(id) sender {
	CCScene *a_p_cls_new_game_scene = [CCScene node];
	[a_p_cls_new_game_scene addChild:[WeaponUpgradesScreen node]];
	
	[[CCDirector sharedDirector] replaceScene: [CCTransitionSlideInR transitionWithDuration:1.2f 
																																										scene:a_p_cls_new_game_scene]];
	
}

/**
 * @brief 继续旧游戏
 *
 * @param[in] nil
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
- (void) continueGame:(id) sender {
	CCScene *a_p_cls_continue_game_scene = [CCScene node];
	[a_p_cls_continue_game_scene addChild:[WeaponUpgradesScreen node]];
	
	[[CCDirector sharedDirector] replaceScene: [CCTransitionSlideInR transitionWithDuration:1.2f 
																																										scene:a_p_cls_continue_game_scene]];
}

/**
 * @brief 进入游戏设置界面
 *
 * @param[in] nil
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
- (void) gameSetting:(id) sender {
	CCScene *a_p_cls_setting_scene = [CCScene node];
	[a_p_cls_setting_scene addChild:[SettingScreen node]];
	
	/// 新场景 从右侧进入屏幕, 并且隐藏旧场景
	[[CCDirector sharedDirector] replaceScene: [CCTransitionSlideInR transitionWithDuration:1.2f 
																																										scene:a_p_cls_setting_scene]];
}

/**
 * @brief 进入游戏帮助界面
 *
 * @param[in] nil
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
-(void) gameHelp: (id) sender {
	CCScene *a_p_cls_help_scene = [CCScene node];
	[a_p_cls_help_scene addChild:[HelpScreen node]];
	
	[[CCDirector sharedDirector] replaceScene: [CCTransitionSlideInR transitionWithDuration:1.2f 
																																										scene:a_p_cls_help_scene]];
}

#pragma mark 初始化函数
/**
 * @brief 初始化函数
 *
 * @param[in] nil
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
- (id) init {

	if ((self = [super init]))
	{
	//	TYAddLifeProps *test = [[TYAddLifeProps alloc] init];
//		
//		[test release];
//		
//		TYFarmer *test1 = [[TYFarmer alloc] init];
//		[test1 addProps:4];
//		[test1 addProps:6];
//		for (id props in test1.m_p_props_array) {
//			NSInteger i = [((NSNumber *)props) intValue];
//			
//			i = i;
//		}
//		
//		[test1 release];
		
		
		
		
		
		CCSprite *a_p_cls_screen_background_picture = [CCSprite spriteWithFile:@"main_screen_bg.png"];
		a_p_cls_screen_background_picture.anchorPoint = CGPointZero;
		
		[self addChild:a_p_cls_screen_background_picture
								 z:0
							 tag:kMainScreenTagBackgroundPicture];
		
		/// [MenuItemFont setFontName:@"Marker Felt"];
		[CCMenuItemFont setFontSize:25];
		
		CCMenuItem *a_p_cls_menu_new_game = [CCMenuItemFont itemFromString:@"新游戏" 
																																target:self 
																															selector:@selector(newGame:)];
		
		CCMenuItem *a_p_cls_menu_continue_game = [CCMenuItemFont itemFromString:@"继续游戏" 
																																		 target:self 
																																	 selector:@selector(continueGame:)];
		
		CCMenuItem *a_p_cls_menu_setting = [CCMenuItemFont itemFromString:@"游戏设置" 
																															 target:self 
																														 selector:@selector(gameSetting:)];
		
		CCMenuItem *a_p_cls_menu_help = [CCMenuItemFont itemFromString:@"游戏帮助" 
																														target:self 
																													selector:@selector(gameHelp:)];
	
		/// 菜单列表
		CCMenu *a_p_cls_menu_list = [CCMenu menuWithItems:a_p_cls_menu_new_game, 
																                      a_p_cls_menu_continue_game, 
																                      a_p_cls_menu_setting, 
																                      a_p_cls_menu_help, 
																											nil];
		[a_p_cls_menu_list alignItemsVertically];
		
		[self addChild:a_p_cls_menu_list 
								 z:1 
							 tag:kMainScreenTagMenuList];
		
	}
	
	return self;
}




@end
